<template>
  <div>
    <Form ref="search" :model="search" :label-width="80">
      <Row>
        <Col span="5" v-if="managerFlag||adminFlag">
          <FormItem label="分配坐席：" prop="assigneTo">
            <Select v-model="search.assigneTo" style="width:200px" :filterable="true">
              <Option value>全部</Option>
              <Option
                :value="item.value"
                v-for=" item in searchAssigneTos"
                :key="item.value"
              >{{item.label}}</Option>
            </Select>
          </FormItem>
        </Col>
        <Col span="5">
          <FormItem label="统计日期:" prop="startDate">
            <DatePicker
              format="yyyy-MM-dd"
              type="date"
              placeholder="开始时间"
              :editable="false"
              v-model="search.startDate"
              @on-change="search.startDate=$event"
              :options="endDateoptions"
              style="width:200px"
            ></DatePicker>
          </FormItem>
        </Col>
        <Col span="4">
          <FormItem :label-width="0" prop="endDate">
            <DatePicker
              format="yyyy-MM-dd"
              type="date"
              placeholder="结束时间"
              v-model="search.endDate"
              @on-change="search.endDate=$event"
              :editable="false"
              style="width:200px"
              :options="endDateoptions"
            ></DatePicker>
          </FormItem>
        </Col>
        <FormItem>
          <Button>
            <Icon type="ios-cloud-download-outline" />下载
          </Button>
        </FormItem>
      </Row>
    </Form>
  </div>
</template>
<script>
import { post } from "@/libs/axios-cfg";
import { checkRole, allRoles } from "@/libs/util";

export default {
  data() {
    return {
      adminFlag: false,
      managerFlag: false,
      salesFlag: false,
      searchAssigneTos: [],
      search: {},
      endDateoptions: {
        disabledDate(date) {
          return date && date.valueOf() > Date.now();
        }
      }
    };
  },
  created() {
    this.salesFlag = checkRole(allRoles.sales);
    this.managerFlag = checkRole(allRoles.manager);
    this.adminFlag = checkRole(allRoles.admin);
  },
  methods: {
    getQueryConfig() {
      var url = "/clue/getQueryConfig";
      this.post(url, {}, {}).then(res => {
        if (this.checkIsSsuccess(res)) {
        } else {
          this.$Message.error({
            content: res["msg"],
            duration: 0,
            closable: true
          });
        }
      });
    }
  }
};
</script>